package com.hejielife.singleton;

// 静态内部类方式，线程安全
public class SingletonDemo03 {
	private SingletonDemo03() {
	}

	public static class SingletonClassInstance {
		private static final SingletonDemo03 singletonDemo03 = new SingletonDemo03();
	}

	// 方法没有同步
	public static SingletonDemo03 getInstance() {
		return SingletonClassInstance.singletonDemo03;
	}

	public static void main(String[] args) {
		SingletonDemo03 s1 = SingletonDemo03.getInstance();
		SingletonDemo03 s2 = SingletonDemo03.getInstance();
		System.out.println(s1 == s2);
	}
}
